//
//  BKMainController.m
//  FastBee
//
//  Created by mac on 16/9/9.
//  Copyright © 2016年 xbk. All rights reserved.
//

#import "BKMainController.h"
#import "BKHomeController.h"
#import "BKMarketController.h"
#import "BKSCartController.h"
#import "BKMeController.h"

@interface BKMainController ()

@end

@implementation BKMainController

+ (void)initialize{
    
    //默认
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    //选中
    NSMutableDictionary *attrSelected = [NSMutableDictionary dictionary];
    attrSelected[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:attrSelected forState:UIControlStateSelected];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithRed:222/255.0 green:222/255.0 blue:222/255.0 alpha:1];

    [self addChildViewController:[[BKHomeController alloc]init] imageName:@"home" titleName:@"首页"];
    [self addChildViewController:[[BKMarketController alloc]init] imageName:@"order" titleName:@"闪电超市"];
    [self addChildViewController:[[BKSCartController alloc]init] imageName:@"shopCart" titleName:@"购物车"];
    [self addChildViewController:[[BKMeController alloc]init] imageName:@"my" titleName:@"我的"];
}

- (void)addChildViewController:(UIViewController *)childController imageName:(NSString *)imageName titleName:(NSString *)titleName{

    childController.tabBarItem.image = [UIImage imageNamed:imageName];
    childController.tabBarItem.selectedImage = [[UIImage imageNamed:[NSString stringWithFormat:@"%@_r",imageName]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childController.title = titleName;
    
    //添加导航控制器
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:childController];
    [self addChildViewController:nav];
    
}


@end
